﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SynoManager.DownloadStation
{
    public class ShareInfo
    {
        private readonly DownloadStationService service;
        private DownloadRedirector.RwShareGetResult shares;

        internal ShareInfo(DownloadStationService service)
        {
            this.service = service;
        }

        public IList<string> Shares
        {
            get
            {
                shares = service.redirector.RwShareGet();
                return shares.items.Select(s => s.name).ToList();
            }
        }

        public string SelectedShare
        {
            get
            {
                if (shares == null)
                    shares = service.redirector.RwShareGet();
                return shares.@default;
            }
            set
            {
                service.redirector.ShareSet(value);
                shares = null; // forces reload next time
            }
        }
    }
}
